import request from '@/utils/request.js'

export const login = (data) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data: data
  })
}

export const sendSmsCode = (mobile) => {
  return request({
    method: 'GET',
    url: '/app/v1_0/sms/codes/' + mobile
  })
}

export const getCurrentUser = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}

export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

export const refreshToken = () => {
  return request({
    method: 'PUT',
    url: '/app/v1_0/authorizations'
  })
}

export const addFollow = (target) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: { target: target }
  })
}

export const cancelFollow = (target) => {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/user/followings/' + target
  })
}

export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

export const updateUserProfile = (user) => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data: user
  })
}

export const updateUserPhoto = (data) => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: data
  })
}
